<template>
  <view class="charts-box">
	<view class="title">
	  	<text>模型在左侧海马体效果</text>
	</view>
    <qiun-data-charts 
      type="line"
      :opts="opts"
      :chartData="left"
    />
	<view class="title">
		<text>模型在右侧海马体效果</text>
	</view>
	<qiun-data-charts
	  type="line"
	  :opts="opts"
	  :chartData="right"
	/>
  </view>
</template>

<script>
export default {
  data() {
    return {
      left: {},
	  right:{},
      //这里的 opts 是图表类型 type="line" 的全部配置参数，您可以将此配置复制到 config-ucharts.js 文件中下标为 ['line'] 的节点中来覆盖全局默认参数。实际应用过程中 opts 只需传入与全局默认参数中不一致的【某一个属性】即可实现同类型的图表显示不同的样式，达到页面简洁的需求。
      opts: {
        timing: "easeOut",
        duration: 1000,
        rotate: false,
        rotateLock: false,
        color: ["#1890FF","#91CB74","#FAC858","#EE6666","#73C0DE","#3CA272","#FC8452","#9A60B4","#ea7ccc"],
        padding: [15,10,0,15],
        fontSize: 13,
        fontColor: "#666666",
        dataLabel: false,
        dataPointShape: true,
        dataPointShapeType: "solid",
        touchMoveLimit: 60,
        enableScroll: false,
        enableMarkLine: false,
        legend: {
          show: true,
          position: "bottom",
          float: "center",
          padding: 5,
          margin: 5,
          backgroundColor: "rgba(0,0,0,0)",
          borderColor: "rgba(0,0,0,0)",
          borderWidth: 0,
          fontSize: 13,
          fontColor: "#666666",
          lineHeight: 11,
          hiddenColor: "#CECECE",
          itemGap: 10
        },
        xAxis: {
          disableGrid: true,
          disabled: false,
          axisLine: true,
          axisLineColor: "#CCCCCC",
          calibration: false,
          fontColor: "#666666",
          fontSize: 13,
          lineHeight: 20,
          marginTop: 0,
          rotateLabel: true,
          rotateAngle: 45,
          labelCount: 4,
          itemCount: 4,
          boundaryGap: "center",
          splitNumber: 5,
          gridColor: "#CCCCCC",
          gridType: "solid",
          dashLength: 4,
          gridEval: 1,
          scrollShow: false,
          scrollAlign: "left",
          scrollColor: "#A6A6A6",
          scrollBackgroundColor: "#EFEBEF",
          title: "",
          titleFontSize: 13,
          titleOffsetY: 0,
          titleOffsetX: 0,
          titleFontColor: "#666666",
          format: ""
        },
		
        yAxis: {
          gridType: "dash",
          dashLength: 2,
          disabled: false,
          disableGrid: false,
          splitNumber: 4,
          gridColor: "#CCCCCC",
          padding: 10,
          showTitle: false,
          data: []
        },
        extra: {
          line: {
            type: "curve",
            width: 2,
            activeType: "hollow",
            linearType: "none",
            onShadow: false,
            animation: "vertical"
          },
		  
          tooltip: {
            showBox: true,
            showArrow: true,
            showCategory: false,
            borderWidth: 0,
            borderRadius: 0,
            borderColor: "#000000",
            borderOpacity: 0.7,
            bgColor: "#000000",
            bgOpacity: 0.7,
            gridType: "solid",
            dashLength: 4,
            gridColor: "#CCCCCC",
            boxPadding: 3,
            fontSize: 13,
            lineHeight: 20,
            fontColor: "#FFFFFF",
            legendShow: true,
            legendShape: "auto",
            splitLine: true,
            horizentalLine: false,
            xAxisLabel: false,
            yAxisLabel: false,
            labelBgColor: "#FFFFFF",
            labelBgOpacity: 0.7,
            labelFontColor: "#666666"
          },
          markLine: {
            type: "solid",
            dashLength: 4,
            data: []
          }
        }
      }
    };
  },
  onReady() {
    this.getServerData();
  },
  methods: {
    getServerData() {
          uni.request({
          	url:"http://127.0.0.1:9099/dice",
    		success: (msg) => {
    			let dice=msg.data.dice
    			let resleft={
    				categories:dice["unetleft"].map(x=>x[1]),
    				series: [
    					{
    						name:"U-Net",
    						data:dice["unetleft"].map(x=>x[2]*100)
    					},
    					{
    						name:"EGE-UNet",
    						data:dice["egeunetleft"].map(x=>x[2]*100)
    					}
    				]
    			}
				let resright={
					categories:dice["unetright"].map(x=>x[1]),
					series: [
						{
							name:"U-Net",
							data:dice["unetright"].map(x=>x[2]*100)
						},
						{
							name:"EGE-UNet",
							data:dice["egeunetright"].map(x=>x[2]*100)
						}
					]
				}
    			this.left = JSON.parse(JSON.stringify(resleft));
				this.right =JSON.parse(JSON.stringify(resright));
    		},
			
          })
        },
  }
};
</script>

<style scoped>
  /* 请根据实际需求修改父元素尺寸，组件自动识别宽高 */
  .charts-box {
    width: 100%;
    height: 350px;
	margin-bottom: 50rpx;
  }
  .title {
    display: flex;
    justify-content: center; /* 水平居中 */
    align-items: center; /* 垂直居中 */
    width: 50%; /* 宽度占满父容器 */
    height: 40px; /* 标题高度 */
    background-color: #ffffff; /* 浅蓝色背景 */
    border: 1px solid #dcdcdc; /* 灰色边框 */
    border-radius: 8px; /* 圆角边框 */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5); /* 阴影效果 */
    margin: 20px 0; /* 上下外边距 */
  }
  
  .title text {
    font-size: 18px; /* 字体大小 */
    font-weight: bold; /* 字体加粗 */
    color: #666666; /* 字体颜色 */
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2); /* 文字阴影 */
  }
</style>